package com.yt.server;

import java.util.Iterator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yt.server.api.IGlobalScope;
import com.yt.server.api.IScope;

/**
 * 世界总域(雏形)
 * 
 * @author 刘晶
 */
public class GlobalScope extends Scope implements IGlobalScope {

	protected static Logger log = LoggerFactory.getLogger(GlobalScope.class);

	/**
	 * 游戏副本ROOT(二叉树)
	 */
	private IScope aloneRoot = null;

	/**
	 * 普通场景ROOT(拓扑树)
	 */
	private IScope commonRoot = null;

	/**
	 * 临时区域
	 */
	private IScope tempRoot = null;

	public GlobalScope() {
		super(GLOBAL_SCOPE_NAME, GLOBAL_SCOPE_PATH);
		log.info("GlobalScope creaded...");
	}

	@Override
	public void init() {
		context = Context.getInstance();
		// aloneRoot,commonRoot,tempRoot无法移除
		// create ALONE_ROOT_NAME
		this.createChildScope(ALONE_ROOT_NAME, TYPE, null, true);
		aloneRoot = this.getScope(ALONE_ROOT_NAME);
		// create COMMON_ROOT_NAME
		this.createChildScope(COMMON_ROOT_NAME, TYPE, null, true);
		commonRoot = this.getScope(COMMON_ROOT_NAME);
		// create TEMP_ROOT
		this.createChildScope(TEMP_ROOT, TYPE, null, true);
		tempRoot = this.getScope(TEMP_ROOT);
		System.out.println("GlobalScope inited.");
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
	}

	@Override
	public Iterator<IScope> getGlobalScopes() {
		return null;
	}

	@Override
	public Iterator<String> getGlobalScopeNames() {
		return null;
	}

	@Override
	public IScope getAloneRoot() {
		return aloneRoot;
	}

	@Override
	public IScope getCommonRoot() {
		return commonRoot;
	}

	@Override
	public IScope getTempRoot() {
		return tempRoot;
	}
}